﻿/* Copyright (C) Siemens AG, 2012. All Rights Reserved.
 * Author: Roland Eckl, Corporate Technology
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


namespace RVM.Infrastructure.Identification
{
    /// <summary>
    /// Delegate for ExportingSource event.
    /// </summary>
    public delegate void ExportingSourceDelegate();
    
    /// <summary>
    /// Interface to provide identifications for the local application and available exporting applications.
    /// TODO: - Add some IsSingleton() or comparable, which means "one identity per process" or "many identities per process" possible.
    /// </summary>
    public interface IIdentificationProvider
    {
        /// <summary>
        /// Scope if IdentificationProvider
        /// </summary>
        IdentityScope Scope { get; }

        /// <summary>
        /// Returns an unique Id for the local exporter.
        /// </summary>
        /// <returns>Unique ID</returns>
        string CreateNewIdentity();

        /// <summary>
        /// Returns a list of all available exporters.
        /// </summary>
        /// <returns>List of unique IDs</returns>
        string[] GetExportingIdentities();

        /// <summary>
        /// Checks whether an ID is used by an active exporter.
        /// </summary>
        /// <param name="identity">ID of exporter</param>
        /// <returns>TRUE, if there is already an exporter with the given ID. FALSE otherwise</returns>
        bool IsExporting(string identity);

        /// <summary>
        /// Event is thrown when a new exporter shows up in the system.
        /// </summary>
        event ExportingSourceDelegate ExportingSource;

        /// <summary>
        /// Signals an identity (e.g. broadcasting new identity).
        /// </summary>
        /// <param name="start">Identity was started or removed</param>
        void Signal(bool start);
    }
}
